package com.emergency.direct.controller;

import com.emergency.direct.service.MonitorService;
import com.emergency.base.domain.Plan;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lijie on 2019/10/21.
 */
@RestController
@RequestMapping("/monitor")
@Api(value="任务监控类",description = "为态势生成系统提供数据支撑")
public class MonitorController {

    @Autowired
    private MonitorService monitorService;

    @ApiOperation(value = "任务进程数据接口" ,  notes="按照计划方案获取当前进程情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "plan", value = "计划方案", required = true, paramType = "query", dataType = "Plan"),
    })
    @RequestMapping(value = "process",method = RequestMethod.POST)
    public Result process(@RequestBody Plan plan){
        String data=monitorService.processData(plan);
        return new Result(true, StatusCode.OK,  "数据获取成功", data);
    }

    @ApiOperation(value = "任务资源数据接口" ,  notes="按照计划方案获取当前资源使用情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "plan", value = "计划方案", required = true, paramType = "query", dataType = "Plan"),
    })
    @RequestMapping(value = "resource",method = RequestMethod.POST)
    public Result resource(@RequestBody  Plan plan){
        String data=monitorService.resourceData(plan);
        return new Result(true, StatusCode.OK,  "数据获取成功", data);
    }
}
